Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.x - RouteCollectorProxy #2641

Merged
merged 11 commits into from
Apr 21, 2019
Merged

Conversation

l0gicgate
Copy link
Member

This is pull 7 out of 7 to complete the goals set in #2604

App now extends RouteCollectorProxy which provides all of the route mapping functionality.

App::group() Breaking Change
There is a breaking change with App::group(). Now the callable gets a RouteCollectorProxyInterface instance injected which used to be App. All of the original route mapping functionality remains intact.

The new interface implements the following methods:

  • RouteCollectorProxy::getCallableResolver()
  • RouteCollectorProxy::getContainer()
  • RouteCollectorProxy::getRouteCollector()
  • RouteCollectorProxy::get()
  • RouteCollectorProxy::post()
  • RouteCollectorProxy::put()
  • RouteCollectorProxy::patch()
  • RouteCollectorProxy::delete()
  • RouteCollectorProxy::options()
  • RouteCollectorProxy::any()
  • RouteCollectorProxy::getBasePath()
  • RouteCollectorProxy::setBasePath()

The following methods on RouteCollectorInterface are removed:

  • RouteCollectorInterface::pushGroup()
  • RouteCollectorInterface::popGroup()

The following method on RouteCollectorInterface is introduced:

  • RouteCollectorInterface::group() which replaces pushGroup() and popGroup()

Example Usage:

use Slim\App;
use Slim\Http\Factory\DecoratedResponseFactory;
use Slim\Http\ServerRequest;
use Slim\Interfaces\RouteCollectorProxyInterface;
use Slim\Psr7\Factory\ResponseFactory;
use Slim\Psr7\Factory\ServerRequestFactory;
use Slim\Psr7\Factory\StreamFactory;

$responseFactory = new DecoratedResponseFactory(new ResponseFactory(), new StreamFactory());
$app = new App($responseFactory);

/**
 * As mentioned above, the breaking change introduced here is
 * that we don't inject App in the route group callable anymore.
 */
$app->group('/app', function (RouteCollectorProxyInterface $group) {
    $group->get('/hello/{name}', function ($request, $response, $args) {
        return $response;
    });
});

$request = new ServerRequest(ServerRequestFactory::createFromGlobals());
$app->run($request);

@l0gicgate l0gicgate added this to the 4.0 milestone Apr 21, 2019
@l0gicgate l0gicgate mentioned this pull request Apr 21, 2019
7 tasks
@l0gicgate l0gicgate merged commit 7377499 into slimphp:4.x Apr 21, 2019
@l0gicgate l0gicgate deleted the 4.x-RouteCollectorProxy branch April 21, 2019 03:55
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.5%) to 97.997% when pulling a5f09ac on l0gicgate:4.x-RouteCollectorProxy into e65a4dc on slimphp:4.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants